<?php

if (eregi("block-Shop.php", $_SERVER['SCRIPT_NAME'])) {
    Header("Location: index.php");
    die();
}


global $prefix, $db, $themepath, $multilingual, $currentlang;

if ($multilingual == 1) {
    $querylang = "AND (clanguage='$currentlang' OR clanguage='')";
} else {
    $querylang = "";
}

$images = "<img src=\"".$themepath."modules/Shop/images/cat_pic.gif\">";
$content = "";
$sql = "SELECT cid, cat_title FROM ".$prefix."_shop_categories where parentid='0' $querylang order by cid, parentid";
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) {
$cid = $row[cid];
$title = $row[cat_title];
$nums = $db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_shop_categories WHERE parentid='$cid'"));
if ($nums  > 0) {
   $cat_l = "cat"; }
   else {
   $cat_l = "showcat"; }
$content .= "$images <a Style=\"cursor: hand; TEXT-DECORATION: none;\" href=\"".$themepath."modules.php?name=Shop&amp;go=$cat_l&amp;cid=$cid\">$title</a><br>";
$sql2 = "SELECT cid, cat_title FROM ".$prefix."_shop_categories where parentid='$cid' order by cid, parentid";
$result2 = $db->sql_query($sql2);
while ($row2 = $db->sql_fetchrow($result2)) {
$cid2 = $row2[cid];
$title2 = $row2[cat_title];
   $sql3 = "SELECT cid  FROM ".$prefix."_shop_categories WHERE parentid = '$cid2'";
   $resnum = $db->sql_query($sql3);
   if ($numrows = $db->sql_numrows($resnum) > 0) {
   $cat_links = "cat"; }
   else {
   $cat_links = "showcat"; }
$content .= "<a style=\"margin-left: 14\" Style=\"cursor: hand; TEXT-DECORATION: none;\" href=\"".$themepath."modules.php?name=Shop&amp;go=$cat_links&amp;cid=$cid2\">$title2</a><br>";

}
}

?>
